<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //回调函数
        //callback 不是给程序员调用的，是给其他函数调用的
        function add(x,y){
            return x+y;
        }
        function sub(x,y){
            return x-y;
        }
        function calc(fn,x,y){
            return fn(x,y);
        }
        console.log(calc(add,3,4));
        console.log(calc(sub,3,4));
        console.log(calc(function(x,y){
            return x*y;
        },3,4));
        console.log(calc(function(x,y){
            return x/y;
        },3,4));
        console.log(
            calc((x,y)=>{return x/y},3,4)    //胖箭头函数=>(省略掉一个function关键字)
        );
    </script>
</body>
</html>